<template>
  <el-dialog
    title="选择审核人"
    :model-value="modelValue"
    @close="closed"
    width="1200px"
  >
    <el-table v-loading="loading" :data="userList">
      <el-table-column
        label="用户名称"
        align="center"
        key="userName"
        prop="userName"
      />
      <el-table-column
        label="用户昵称"
        align="center"
        key="nickName"
        prop="nickName"
      />
      <el-table-column
        label="部门"
        align="center"
        key="deptName"
        prop="dept.deptName"
      />
      <el-table-column
        label="手机号码"
        align="center"
        key="phonenumber"
        prop="phonenumber"
        width="120"
      />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding"
        width="200"
      >
        <template #default="scope">
          <el-button type="text" @click="handleSelect(scope.row)">选择</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />

    <template #footer>
      <span class="dialog-footer">
        <el-button @click="closed">关闭</el-button>
      </span>
    </template>
  </el-dialog>
</template>
  
  <script setup>

import { listXgsDataPUser } from "@/api/system/user";

const { proxy } = getCurrentInstance();



defineProps({
  modelValue: {
    type: Boolean,
    required: true,
  },
});

const emits = defineEmits(["update:modelValue", "select"]);

const userList = ref([]);

const loading = ref(false);
const total = ref(0);

const data = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
  },
});

const { queryParams } = toRefs(data);


/** 查询风控计划列表 */
function getList() {
  loading.value = true;
  listXgsDataPUser(queryParams.value).then(res => {
    loading.value = false;
    userList.value = res.rows;
    total.value = res.total;
  });
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}

function handleSelect(row) {
  emits("select", row);
  emits("update:modelValue", false);
}

/*** 关闭*/
const closed = () => {
  emits("update:modelValue", false);
};

getList()

</script>